
#include<iostream>


class Base
{
public:
    void show()
    {
        std::cout<<"Base"<<std::endl;

    }
protected:
    int a;
};

class Derived1:public Base
{
public:
    void show()
    {
        std::cout<<"Derived"<<std::endl;
    }
};

class Derived2:public Base{
public:
    void show()
    {
        std::cout<<"Derived"<<std::endl;
    }
};

int main ()
{
    //向上转型(必须有继承关系)
    // ;Base* d = new Derived();///用基类指针指向子类对象√
    // d->show();

    Base* a[2];
    a[0] = new Derived1;
    a[1] = new Derived2;

//多态(多种形态)->函数有多种形态
    for (int i=0;i<2;i++)
    {
        a[i]->show();
    }
     return 0;  
}